var t = require("../../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../../utils/util")), a = require("../../../../utils/themeSkin/skinBehavior"), e = getApp();

Page({
    behaviors: [ a ],
    data: {
        isShowCalendar: !1,
        currentTime: "",
        timeText: "",
        markDate: [],
        resData: null,
        cumulative: {},
        history: [],
        port: [],
        rank: [],
        member: [],
        tabInd: 1,
        startTime: "",
        endtime: "",
        isLoadMore: !0,
        total_page: 0,
        page: 1
    },
    onLoad: function(a) {
        a.is_type && this.setData({
            is_type: a.is_type
        }), this.setData({
            startTime: t.default.formatTimes(new Date()),
            timeText: t.default.formatTimes(new Date())
        }), this.setData({
            endtime: "".concat(Number(this.data.startTime.slice(0, 4)) - 10).concat(this.data.startTime.slice(4))
        }), console.log(this.data.endtime, "dddddddd"), this.getData(), this.getList();
    },
    selectTab: function(t) {
        var a = t.currentTarget.dataset.key;
        this.setData({
            tabInd: a
        }), this.init(), this.getList();
    },
    confirm: function(t) {
        this.setData({
            timeText: t.detail.value
        }), this.init(), this.getData(), this.getList();
    },
    init: function() {
        this.isLoadMore = !0, this.setData({
            top_list: [],
            page: 1,
            total_page: 0
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {},
    getData: function() {
        var t = this, a = {};
        a.level_type = this.data.is_type, a.date = this.data.timeText;
        var i = e.getNetAddresss("plugin.customer-center.frontend.controllers.browse.index");
        e._getNetWork({
            url: i,
            data: a,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.setData({
                    history: e.data.history_data,
                    port: e.data.port_data,
                    visit_data: e.data.visit_data,
                    display_set: e.data.display_set
                }), wx.setNavigationBarColor({
                    frontColor: "#ffffff",
                    backgroundColor: t.data.themeBaseColor,
                    animation: {
                        duration: 400,
                        timingFunc: "easeIn"
                    }
                }), wx.setNavigationBarTitle({
                    title: "轨迹追踪"
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getList: function() {
        var t = this, a = {};
        a.level_type = this.data.is_type, a.date = this.data.timeText, a.top_type = this.data.tabInd;
        var i = e.getNetAddresss("plugin.customer-center.frontend.controllers.browse.get-record-list");
        e._getNetWork({
            url: i,
            data: a,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.data.isLoadMore = !0, t.data.total_page = e.data.top_list.last_page, 
                t.data.total_page || (t.data.total_page = 0), t.setData({
                    top_list: e.data.top_list.data
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var t = this, a = "";
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            var i = {};
            i.level_type = this.data.is_type, i.date = this.data.timeText, i.top_type = this.data.tabInd, 
            this.data.page = this.data.page + 1, i.page = this.data.page, a = e.getNetAddresss("plugin.customer-center.frontend.controllers.browse.get-record-list"), 
            e._postNetWork({
                url: a,
                data: i,
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? (t.data.isLoadMore = !0, t.setData({
                        top_list: t.data.top_list.concat(e.data.top_list.data)
                    })) : (t.data.page = t.data.page - 1, t.isLoadMore = !1, wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    }
});